<nav class="navbar-default navbar-static-side" role="navigation">
  <div class="content">

    <div id="jquery-accordion-menu" class="jquery-accordion-menu" style="background-color: #2F4050; width: 20px" >
      <ul id="demo-list">

        <li class="nav-header">
          <div class="dropdown profile-element">
            <span>
              <%= image_tag 'avatar.png', class:'img-circle'%>
            </span>
            <span class="clear">
              <span class="block m-t-xs">
                <strong class="font-bold">你好， <%= current_admin.name %></strong>
              </span>
            </span>
          </div>
          <div class="logo-element">
            CLOUDSIGNIN
          </div>
        </li>

        <li class="<%= 'active' if @current_module.blank? %>">
          <%= link_to event_dashboard_path do%>
            <i class="fa fa-th-large"></i> <span class="nav-label">基本信息设置</span></span>
          <% end %>
        </li>

        <% if @current_module==6 %>
          <li id="active-item" class="active">
        <% else %>
          <li>
        <% end %>
        <a href="#">
          <i class="fa fa-home" aria-hidden="true"></i><span class="nav-label">活动微网站</span>
        </a>
        <ul class="submenu">
          <li>
            <%= link_to event_event_base_setting_path(current_event), style: is_active_item('events', 'event_base_setting') do %>
              <i class="fa fa-cog" aria-hidden="true"></i>
              <span class="nav-label">基本设置</span>
            <% end %>
          </li>
          <li>
            <%= link_to event_welcome_page_setting_path(current_event), style: is_active_item('events', 'welcome_page_setting') do %>
              <i class="fa fa-star" aria-hidden="true"></i>
              <span class="nav-label">欢迎页设置</span>
            <% end %>
          </li>
          <li>
            <%= link_to event_welcome_page_drage_setting_path(current_event), style: is_active_item('events', 'welcome_page_drage_setting') do %>
              <i class="fa fa-hand-o-up" aria-hidden="true"></i>
              <span class="nav-label">拖拽设置</span>
            <% end %>
          </li>
          <li>
            <%= link_to event_function_setting_path(current_event), style: is_active_item('events', 'function_setting') do %>
              <i class="fa fa-wrench" aria-hidden="true"></i>
              <span class="nav-label">功能设置</span>
            <% end %>
          </li>
          <li>
            <%= link_to event_content_setting_path(current_event), style: is_active_item('events', 'content_setting') do %>
              <i class="fa fa-newspaper-o" aria-hidden="true"></i>
              <span class="nav-label">内容设置</span>
            <% end %>
          </li>
        </ul>
        </li>

        <% if @current_module==0 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.session_manage_permission%>">
        <% end %>
          <a id="conference" href="#"><i class="fa fa-tachometer" aria-hidden="true"></i>会议管理</a>
          <ul class="submenu">
            <li>
              <%= link_to event_activities_path, style: is_active_item('activities') do %>
                <i class="fa fa-gamepad"></i><span class="nav-label">活动管理</span></a>
              <% end %>
            </li>
            <li>
              <%= link_to event_event_session_locations_path, style: is_active_item('event_session_locations') do %>
                <i class="fa fa-building" aria-hidden="true"></i>
                <span class="nav-label">会议场地管理</span></a>
              <% end %>
            </li>
            <li>
              <%= link_to event_activity_categories_path, style: is_active_item('activity_categories') do %>
                <i class="fa fa-sitemap"></i><span class="nav-label">活动标签</span></a>
              <% end %>
            </li>
            <li><%= link_to event_sessions_path, style: is_active_item('event_sessions') do %>
              <i class="fa fa-comments"></i>
              <span class="nav-label">会议日程管理</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_recommends_path, style: is_active_item('recommends')  do %>
              <i class="fa fa-bullhorn"></i>
              <span class="nav-label">周边推荐</span>
              <% end %>
            </li>
          </ul>
        </li>

        <% if @current_module==1 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.session_notifacation_permission%>">
        <% end %>
          <a href="#"><i class="fa fa-volume-up" aria-hidden="true"></i>会议通知</a>
          <ul class="submenu">
            <li>
              <%= link_to event_invitation_settings_path, style: is_active_item('invitation_settings') do %>
                <i class="fa fa-envelope"></i>
                <span class="nav-label">电子邀请函</span></span>
              <% end %>
            <li>
              <%= link_to event_notifications_path, style: is_active_item('notifications') do %>
                <i class="fa fa-bell"></i>
                <span class="nav-label">会议通知管理</span></span>
              <% end %>
            </li>
            <li>
              <%= link_to event_system_infos_path, style: is_active_item('system_infos') do %>
                <i class="fa fa-bell"></i>
                <span class="nav-label">系统消息</span></span>
              <% end %>
            </li>
          </ul>
        </li>

        <% if @current_module==2 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.attendee_manage_permission%>">
        <% end %>
        <a href="#"><i class="fa fa-users" aria-hidden="true"></i>嘉宾管理</a>
          <ul class="submenu">
            <li>
              <%= link_to event_attendee_categories_path, style: is_active_item('attendee_categories') do %>
                <i class="fa fa-sitemap"></i>
                <span class="nav-label">嘉宾标签管理</span>
              <% end %>
            <li>
              <%= link_to event_attendees_path, style: is_active_item('attendees', 'index') do %>
                <i class="fa fa-user"></i>
                <span class="nav-label">嘉宾信息</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_photos_path, style: is_active_item('attendees', 'photos') do %>
                <i class="fa fa-picture-o"></i>
                <span class="nav-label">嘉宾照片管理</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_photos_path, class: 'hidden' do %>
                <i class="fa fa-picture-o"></i>
                <span class="nav-label">入住信息</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_attentee_rfids_path, style: is_active_item('attentee_rfids') do %>
                <i class="fa fa-barcode"></i>
                <span class="nav-label">嘉宾RFID信息录入</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_set_seat_path(current_event), style: is_active_item('seats') do %>
                <i class="fa fa-asterisk"></i>
                <span class="nav-label">座位安排</span>
              <% end %>
            </li>
            <li>
              <%= link_to edit_event_session_seat_path(current_event, '~'), style: is_active_item('session_seats') do %>
                <i class="fa fa-eye"></i>
                <span class="nav-label">座位查询设置</span>
              <% end %>
            </li>
          </ul>
        </li>

        <% if @current_module==3 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.checkin_manage_permission%>">
        <% end %>
        <a href="#"><i class="fa fa-pencil"></i>签到管理 </a>
          <ul class="submenu">
            <li>
              <%= link_to event_checkin_monitors_path, style: is_active_item('checkin_monitors') do %>
                <i class="fa fa-laptop"></i>
                <span class="nav-label">签到监控设置</span></span>
              <% end %>
            </li>
            <li>
              <%= link_to event_checkin_path, style: is_active_item('checkin') do %>
                <i class="fa fa-laptop"></i>
                <span class="nav-label">签到状态</span></span>
              <% end %>
            </li>
            <li>
              <%= link_to event_prints_path, style: is_active_item('prints') do %>
                <i class="fa fa-print"></i> <span class="nav-label">证件打印状态</span></span>
              <% end %>
            </li>
          </ul>
        </li>
<!-- 
        <% if @current_module==4 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.interaction_manage_permission%>">
        <% end %>
        <a href="#"><i class="fa fa-gift"></i>现场互动管理</a>
          <ul class="submenu">
            <li>
              <%= link_to event_event_lottery_prizes_path(current_event), style: is_active_item('lottery_prizes') do %>
                <i class="fa fa-gift"></i>
                <span class="nav-label">现场抽奖管理</span>
              <% end %>
            </li>
            <li>
              <%= link_to event_event_questions_path(current_event), style: is_active_item('event_questions') do %>
                <i class="fa fa-question" aria-hidden="true"></i>
                <span class="nav-label">现场提问</span><span class="jquery-accordion-menu-label hidden">10 </span>
              <% end %>
            </li>
          </ul>
        </li>
 -->
<!--
        <% if @current_module==5 %>
          <li id="active-item" class="active">
        <% else %>
          <li class="<%= 'hidden' if !current_admin.seller_manage_permission%>">
        <% end %>
          <%= link_to event_sellers_path do %>
            <i class="fa fa-user"></i>销售员管理
          <% end %>
        </li>
-->
        
<!--         <li><%= link_to event_attendee_seats_path do %>
          <i class="fa fa-asterisk"></i><span class="nav-label">座位查询</span>
        <% end %></li> -->

        <li><%= link_to event_site_path do %>
          <i class="fa fa-qrcode"></i> <span class="nav-label">现场签到管理</span>
        <% end %></li>

<!--         <li><%= link_to new_seller_event_session_path do %>
          <i class="fa fa-qrcode"></i> <span class="nav-label">销售登录</span>
        <% end %></li> -->

        <li class="hidden"><%= link_to event_live_lottery_prize_path(current_event) do %>
          <i class="fa fa-qrcode"></i> <span class="nav-label">开始抽奖</span>
        <% end %></li>

        <li class="hidden">
          <%= link_to event_choose_event_question_path(current_event) do %>
          <i class="fa fa-list" aria-hidden="true"></i>
          <span class="nav-label">问题列表</span>
        <% end %>
        </li>
      </ul>
    </div>
  </div>
</nav>

<script type="text/javascript">
; (function($, window, document, undefined) {
    var pluginName = "jqueryAccordionMenu";
    var defaults = {
        speed: 300,
        showDelay: 0,
        hideDelay: 0,
        singleOpen: true,
        clickEffect: true
    };
    function Plugin(element, options) {
        this.element = element;
        this.settings = $.extend({},
        defaults, options);
        this._defaults = defaults;
        this._name = pluginName;
        this.init()
    };
    $.extend(Plugin.prototype, {
        init: function() {
            this.openSubmenu();
            this.submenuIndicators();
            if (defaults.clickEffect) {
                this.addClickEffect()
                //This ia add by yuan lun chuan add
                var li = $("#demo-list").find("#active-item");
                li.children(".submenu").delay(0).slideDown(0);
                li.children(".submenu").siblings("a").addClass("submenu-indicator-minus");
                li.siblings().children(".submenu").slideUp(0);
                li.siblings().children(".submenu").siblings("a").removeClass("submenu-indicator-minus");
            }
        },
        openSubmenu: function() {
            $(this.element).children("ul").find("li").bind("click touchstart",
            function(e) {
                e.stopPropagation();
                e.preventDefault();
                if ($(this).children(".submenu").length > 0) {
                    if ($(this).children(".submenu").css("display") == "none") {
                        $(this).children(".submenu").delay(defaults.showDelay).slideDown(defaults.speed);
                        $(this).children(".submenu").siblings("a").addClass("submenu-indicator-minus");
                        if (defaults.singleOpen) {
                            $(this).siblings().children(".submenu").slideUp(defaults.speed);
                            $(this).siblings().children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
                        }
                        return false
                    } else {
                        $(this).children(".submenu").delay(defaults.hideDelay).slideUp(defaults.speed)
                    }
                    if ($(this).children(".submenu").siblings("a").hasClass("submenu-indicator-minus")) {
                        $(this).children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
                    }
                }
                window.location.href = $(this).children("a").attr("href")
            })
        },
        submenuIndicators: function() {
            if ($(this.element).find(".submenu").length > 0) {
                $(this.element).find(".submenu").siblings("a").append("<span class='submenu-indicator'>+</span>")
            }
        },
        addClickEffect: function() {
            var ink, d, x, y;
            $(this.element).find("a").bind("click touchstart",
            function(e) {
                $(".ink").remove();
                if ($(this).children(".ink").length === 0) {
                    $(this).prepend("<span class='ink'></span>")
                }
                ink = $(this).find(".ink");
                ink.removeClass("animate-ink");
                if (!ink.height() && !ink.width()) {
                    d = Math.max($(this).outerWidth(), $(this).outerHeight());
                    ink.css({
                        height: d,
                        width: d
                    })
                }
                x = e.pageX - $(this).offset().left - ink.width() / 2;
                y = e.pageY - $(this).offset().top - ink.height() / 2;
                ink.css({
                    top: y + 'px',
                    left: x + 'px'
                }).addClass("animate-ink")
            })
        }
    });
    $.fn[pluginName] = function(options) {
        this.each(function() {
            if (!$.data(this, "plugin_" + pluginName)) {
                $.data(this, "plugin_" + pluginName, new Plugin(this, options))
            }
        });
        return this
    };

})(jQuery, window, document);

jQuery(document).ready(function () {
  jQuery("#jquery-accordion-menu").jqueryAccordionMenu();
});

$(function(){ 
  //顶部导航切换
  $("#demo-list li").click(function(){
    $("#demo-list li.active").removeClass("active")
    $(this).addClass("active");
  })
})
</script>
